{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cd28e1fc",
   "metadata": {},
   "source": [
    "# 来自课外题目"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7afd010b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入一个数字: 3\n",
      "3 是奇数\n"
     ]
    }
   ],
   "source": [
    "num = int(input(\"输入一个数字: \"))\n",
    "if (num % 2) == 0:\n",
    "   print(\"{0} 是偶数\".format(num))\n",
    "else:\n",
    "   print(\"{0} 是奇数\".format(num))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "74025a88",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入区间最小值: 1\n",
      "输入区间最大值: 129\n",
      "2\n",
      "3\n",
      "5\n",
      "7\n",
      "11\n",
      "13\n",
      "17\n",
      "19\n",
      "23\n",
      "29\n",
      "31\n",
      "37\n",
      "41\n",
      "43\n",
      "47\n",
      "53\n",
      "59\n",
      "61\n",
      "67\n",
      "71\n",
      "73\n",
      "79\n",
      "83\n",
      "89\n",
      "97\n",
      "101\n",
      "103\n",
      "107\n",
      "109\n",
      "113\n",
      "127\n"
     ]
    }
   ],
   "source": [
    "# 取出范围内的素数\n",
    "lower = int(input(\"输入区间最小值: \"))\n",
    "upper = int(input(\"输入区间最大值: \"))\n",
    " \n",
    "for num in range(lower,upper + 1):\n",
    "    # 素数大于 1\n",
    "    if num > 1:\n",
    "        for i in range(2,num):\n",
    "            if (num % i) == 0:\n",
    "                break\n",
    "        else:\n",
    "            print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7a9dc231",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1x1=1\t\n",
      "1x2=2\t2x2=4\t\n",
      "1x3=3\t2x3=6\t3x3=9\t\n",
      "1x4=4\t2x4=8\t3x4=12\t4x4=16\t\n",
      "1x5=5\t2x5=10\t3x5=15\t4x5=20\t5x5=25\t\n",
      "1x6=6\t2x6=12\t3x6=18\t4x6=24\t5x6=30\t6x6=36\t\n",
      "1x7=7\t2x7=14\t3x7=21\t4x7=28\t5x7=35\t6x7=42\t7x7=49\t\n",
      "1x8=8\t2x8=16\t3x8=24\t4x8=32\t5x8=40\t6x8=48\t7x8=56\t8x8=64\t\n",
      "1x9=9\t2x9=18\t3x9=27\t4x9=36\t5x9=45\t6x9=54\t7x9=63\t8x9=72\t9x9=81\t\n"
     ]
    }
   ],
   "source": [
    "# 九九乘法表\n",
    "for i in range(1, 10):\n",
    "    for j in range(1, i+1):\n",
    "        print('{}x{}={}\\t'.format(j, i, i*j), end='')\n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "eea7c09d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入数字：10\n",
      "十进制数为： 10\n",
      "转换为二进制为： 0b1010\n",
      "转换为八进制为： 0o12\n",
      "转换为十六进制为： 0xa\n"
     ]
    }
   ],
   "source": [
    "# 获取用户输入十进制数\n",
    "dec = int(input(\"输入数字：\"))\n",
    " \n",
    "print(\"十进制数为：\", dec)\n",
    "print(\"转换为二进制为：\", bin(dec))\n",
    "print(\"转换为八进制为：\", oct(dec))\n",
    "print(\"转换为十六进制为：\", hex(dec))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ce0f0584",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入年份: 2021\n",
      "输入月份: 11\n",
      "   November 2021\n",
      "Mo Tu We Th Fr Sa Su\n",
      " 1  2  3  4  5  6  7\n",
      " 8  9 10 11 12 13 14\n",
      "15 16 17 18 19 20 21\n",
      "22 23 24 25 26 27 28\n",
      "29 30\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 引入日历模块\n",
    "import calendar\n",
    " \n",
    "# 输入指定年月\n",
    "yy = int(input(\"输入年份: \"))\n",
    "mm = int(input(\"输入月份: \"))\n",
    " \n",
    "# 显示日历\n",
    "print(calendar.month(yy,mm))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0a1bf4f1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
